package com.frikinet.lifeguard.gui;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import com.frikinet.lifeguard.App;
import com.frikinet.lifeguard.events.PostSelectedEvent;
import com.frikinet.lifeguard.events.PostSelectedListener;

public class PostViewer extends JPanel implements PostSelectedListener
{
	private static final long serialVersionUID = 1L;
	
	private JTabbedPane tabs;
	
	public PostViewer()
	{
		super(new BorderLayout());
		
		buildGUI();
		
		App.events.addPostSelectedListener(this);
	}
	
	private void buildGUI()
	{
		add(new PostNavigation(), BorderLayout.NORTH);
		
		tabs = new JTabbedPane(JTabbedPane.BOTTOM);
		tabs.addTab(App.i18n.translate("comp.post.tabs.post"), new PostHtmlPanel());
		tabs.addTab(App.i18n.translate("comp.post.tabs.comments"), new CommentsHtmlPanel());
		
		add(tabs, BorderLayout.CENTER);
	}

	@Override
	public void postSelected(PostSelectedEvent event)
	{
		tabs.setSelectedIndex(0);
	}
}
